#include<iostream>
using namespace std;
const int N = 110;
char s[N][N];
int a[N];
int n, k;
int main()
{
	int t;
	cin >> t;
	while (t--) {
		cin >> n >> k;
		for (int i = 0; i < n; i++) {
			scanf("%s", s[i]);
		}
		if (n == 1) {
			cout << 1 << endl;
			continue;
		}
		bool f = 0;
		for (int i = 0; i < k; i++) {
			int cnt1 = 0, cnt2 = 0;
			for (int j = 0; j < n; j++) {
				if (s[i][j] == '+')cnt1++;
			}
			cnt2 = n - cnt1;
			if (cnt1 > cnt2)a[i] = 1;
			else if (cnt1 == cnt2)f = 1;
			else a[i] = 2;
		}
		for (int i = 0; i < k; i++) {
			cout << a[i] << " ";
		}
		if (f) {
			cout << 0 << endl;
			continue;
		}
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			bool flag = 0;
			for (int j = 0; j < k; j++) {
				int b = 1;
				if (s[i][j] == '-')b = 2;
				if (a[i] != b) {
					flag = 1;
					break;
				}
			}
			if (!flag)cnt++;
		}
		cout << cnt << endl;
	}
	return 0;
}